
# 使用matplotlib呈现出中国每个城市的店铺数量


import pandas as pd
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
import matplotlib
my_font = FontProperties(fname='/usr/share/fonts/truetype/arphic/ukai.ttc')
# font = {'size':120}
# matplotlib.rc('font',**font)


file_path = './starbucks_store_worldwide.csv'
df = pd.read_csv(file_path)
df = df[df['Country'] == 'CN']

# 利用groupby来实现
#          groupby类型          dataframe类型  series类型  排序                取值
data = df.groupby(by='City').count()['Brand'].sort_values(ascending=False)[:25]

_x = data.index
_y = data.values
print(_x)

plt.figure(figsize=(20,8), dpi=8)
plt.bar(range(len(_x)), _y,width=0.4)


plt.xticks(range(len(_x)), _x, fontproperties=my_font)
plt.show()







